import request from '@/util/request.js'
// import store from '@/store'

export const login = data => {
  return request({
    method: 'POST',
    url: '/app/v1_0/authorizations',
    data
  })
}

// 获取验证码
export const getSmsCode = mobile => {
  return request({
    method: 'GET',
    url: `/app/v1_0/sms/codes/${mobile}`
  })
}

// 获取用户数据
export const getUserInfo = () => {
  return request({
    method: 'GET',
    url: '/app/v1_0/user'
    // headers: {
    //   Authorization: `Bearer ${store.state.user.token}`
    // }
  })
}

// 获取用户自己的信息
export const getUserChannels = () => {
  return request({
    method: 'GET',
    url: '/app/v1_0/user/channels'
  })
}

// 获取用户个人资料
export const getProfileInfo = () => {
  return request({
    method: 'GET',
    url: '/app/v1_0/user/profile'
  })
}

// 更新用户个人资料
export const updateProfileInfo = data => {
  return request({
    method: 'PATCH',
    url: 'http://ttapi.research.itcast.cn/app/v1_0/user/profile',
    data
  })
}

// // 编辑用户照片资料
// export const updateUserPhoto = data => {
//   return request({
//     method: 'PATCH',
//     url: 'http://ttapi.research.itcast.cn/app/v1_0/user/photo',
//     data
//   })
// }
/**
 * 更新用户照片资料
 */
export const updateUserPhoto = data => {
  return request({
    method: 'PATCH',
    url: '/app/v1_0/user/photo',
    data
  })
}
